<!DOCTYPE html>
<html>
  <!-- Html Head Tag-->
  <head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <meta name="author" content="Rms">
  <!-- Open Graph Data -->
  <meta property="og:title" content="Xshell操作Linux中Redis"/>
  <meta property="og:description" content="" />
  <meta property="og:site_name" content="帅的一逼"/>
  <meta property="og:type" content="article" />
  <meta property="og:image" content="http://shsa.gitee.io"/>
  
    <link rel="alternate" href="/atom.xml" title="帅的一逼" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  

  <!-- Site Title -->
  <title>帅的一逼</title>

  <!-- Bootstrap CSS -->
  
<link rel="stylesheet" href="/myblog/css/bootstrap.min.css">

  <!-- Custom CSS -->
  
  
<link rel="stylesheet" href="/myblog/css/style.light.css">


  <!-- Google Analytics -->
  

<meta name="generator" content="Hexo 4.2.1"></head>

  <body>
    <!-- Page Header -->


<header class="site-header header-background" style="background-image: url(/myblog//img/i.jpg)">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <div class="page-title with-background-image">
          <p class="title">Xshell操作Linux中Redis</p>
          <p class="subtitle"></p>
        </div>
        <div class="site-menu with-background-image">
          <ul>
            
              <li>
                <a href="/myblog/">
                  
                  Home
                  
                </a>
              </li>
            
              <li>
                <a href="/myblog/archives">
                  
                  Archives
                  
                </a>
              </li>
            
              <li>
                <a href="/myblog/about">
                  
                  About
                  
                </a>
              </li>
            
          </ul>
        </div>
      </div>
    </div>
  </div>
</header>

<article>
  <div class="container typo">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <div class="post-info text-muted">
          
            <!-- Author -->
            <span class="author info">By Rms</span>
          
          <!-- Date -->
          <span class="date-time info">On
            <span class="date">2020-07-15</span>
            <span class="time">21:53:53</span>
          </span>
          
        </div>
        <!-- Tags -->
        
        <!-- Post Main Content -->
        <div class="post-content">
          <h1 id="Xshell操作Linux中的Redis"><a href="#Xshell操作Linux中的Redis" class="headerlink" title="Xshell操作Linux中的Redis"></a>Xshell操作Linux中的Redis</h1><h2 id="Linux"><a href="#Linux" class="headerlink" title="Linux"></a>Linux</h2><h3 id="准备环境"><a href="#准备环境" class="headerlink" title="准备环境"></a>准备环境</h3><p>先要下载一个虚拟机托管Linux系统</p>
<p>VMware Workstation:<a href="https://www.vmware.com/cn/products/workstation-pro/workstation-pro-evaluation.html" target="_blank" rel="noopener">下载地址</a></p>
<p>下载镜像Linux的镜像文件:<a href="http://mirrors.aliyun.com/centos/7/isos/x86_64/" target="_blank" rel="noopener">下载地址</a></p>
<p>JDK下载:<a href="https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html" target="_blank" rel="noopener">下载地址</a></p>
<p>类型: Centos7+   乌班图  红旗 RedHat…</p>
<h3 id="安装VM"><a href="#安装VM" class="headerlink" title="安装VM"></a>安装VM</h3><p>步骤省略(直接下一步)</p>
<p>记得勾选增强键盘驱动</p>
<p>取消用户体验和更新</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">#激活码</span><br><span class="line">UY758-<span class="number">0</span>RXEQ-M81WP-<span class="number">8</span>ZM7Z-Y3HDA</span><br><span class="line">VF750-<span class="number">4</span>MX5Q-<span class="number">488</span>DQ-<span class="number">9</span>WZE9-ZY2D6</span><br><span class="line">UU54R-FVD91-<span class="number">488</span>PP-<span class="number">7</span>NNGC-ZFAX6</span><br><span class="line">YC74H-FGF92-<span class="number">081</span>VZ-R5QNG-P6RY4</span><br><span class="line">YC34H-<span class="number">6</span>WWDK-<span class="number">085</span>MQ-JYPNX-NZRA2</span><br></pre></td></tr></table></figure>

<p>安装完成的界面</p>
<p><img src="D:%5Cmyblog%5Csource_posts%5CXshell%E6%93%8D%E4%BD%9CLinux%E4%B8%ADRedis%5C1594692674552.png" alt="1594692674552"></p>
<h3 id="安装Linux镜像"><a href="#安装Linux镜像" class="headerlink" title="安装Linux镜像"></a>安装Linux镜像</h3><p>安装步骤省略(具体百度)</p>
<p>记得配置网络…</p>
<p>记得设置用户名和密码</p>
<p>安装xshell和xftp</p>
<h3 id="Linux命令"><a href="#Linux命令" class="headerlink" title="Linux命令"></a>Linux命令</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">鼠标移出虚拟机</span></span><br><span class="line">ctrl+alt</span><br><span class="line"><span class="meta">#</span><span class="bash"> 查看网络地址(主机号)</span></span><br><span class="line">ip addr</span><br><span class="line"><span class="meta">#</span><span class="bash">切换文件目录</span></span><br><span class="line">cd(change directory)</span><br><span class="line"><span class="meta">#</span><span class="bash">切换到根目录</span></span><br><span class="line">cd /</span><br><span class="line"><span class="meta">#</span><span class="bash">打印当前的工作目录</span></span><br><span class="line">pwd(print working directory)</span><br><span class="line"><span class="meta">#</span><span class="bash">查看根目录下有哪些文件</span></span><br><span class="line">ls(list)</span><br><span class="line"><span class="meta">#</span><span class="bash">如果是显示白色的,说明是文件  蓝色的是文件夹</span></span><br><span class="line"><span class="meta">#</span><span class="bash">查看文件(更加详细)</span></span><br><span class="line">ll(ls -l)</span><br><span class="line"><span class="meta">#</span><span class="bash">列出所有的文件(包含隐藏文件)</span></span><br><span class="line">ls -a</span><br><span class="line"><span class="meta">#</span><span class="bash">切换文件夹(别任何时候都在前面加/   /代表的时候根目录)</span></span><br><span class="line">cd /home</span><br><span class="line"><span class="meta">#</span><span class="bash">创建文件夹</span></span><br><span class="line">mkdir(make directory) jdk</span><br><span class="line"><span class="meta">#</span><span class="bash">切换到jdk目录  使用tab进行目录补全</span></span><br><span class="line">cd jdk/</span><br><span class="line"><span class="meta">#</span><span class="bash">回到上一级</span></span><br><span class="line">cd ..</span><br><span class="line"><span class="meta">#</span><span class="bash">打开xfp把tomcat和jdk分别放到两个文件夹下面</span></span><br><span class="line"><span class="meta">#</span><span class="bash">创建空文件</span></span><br><span class="line">touch a.txt</span><br><span class="line"><span class="meta">#</span><span class="bash">查看文件的内容</span></span><br><span class="line">cat a.txt</span><br><span class="line"><span class="meta">#</span><span class="bash">创建带内容的文件</span></span><br><span class="line">echo "ange是大帅逼"&gt;b.txt</span><br><span class="line"><span class="meta">#</span><span class="bash">替换内容和追加内容 &gt;替换 &gt;&gt;追加</span></span><br><span class="line"><span class="meta">#</span><span class="bash">复制文件</span></span><br><span class="line">cp(copy) b.txt c.txt</span><br><span class="line">cp b.txt /usr/</span><br><span class="line"><span class="meta">#</span><span class="bash">剪切</span></span><br><span class="line">mv(move) c.txt /home</span><br><span class="line"><span class="meta">#</span><span class="bash">重命名</span></span><br><span class="line">mv c.txt d.txt</span><br><span class="line"><span class="meta">#</span><span class="bash">删除文件</span></span><br><span class="line">rm(remove) d.txt</span><br><span class="line"><span class="meta">#</span><span class="bash">删除文件夹</span></span><br><span class="line"><span class="meta">#</span><span class="bash">rm springboot-redis是报错的</span></span><br><span class="line"><span class="meta">#</span><span class="bash">-r是代表递归删除</span></span><br><span class="line">rm -r springboot-redis</span><br><span class="line"><span class="meta">#</span><span class="bash">-f是强制删除没有任何提示(谨慎使用)</span></span><br><span class="line">rm -rf springboot-redis</span><br><span class="line"><span class="meta">#</span><span class="bash">查看端口</span></span><br><span class="line">ps -a</span><br><span class="line"><span class="meta">#</span><span class="bash">查询tomcat是否启动</span></span><br><span class="line">ps -ef | grep tomcat</span><br><span class="line"><span class="meta">#</span><span class="bash">查看内存情况</span></span><br><span class="line">htop</span><br><span class="line"><span class="meta">#</span><span class="bash">解压文件</span></span><br><span class="line">rpm -ivh ...rpm</span><br><span class="line">tar -zxvf ...tar.gz</span><br><span class="line">tar -zxvf jdk-8u221-linux-x64.tar.gz</span><br><span class="line"><span class="meta">#</span><span class="bash">配置环境变量</span></span><br><span class="line">vi /etc/profile</span><br><span class="line"><span class="meta">#</span><span class="bash">将下面的复制到该文件的最末尾</span></span><br><span class="line">JAVA_HOME=/usr/local/jdk8</span><br><span class="line">CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib</span><br><span class="line">PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin</span><br><span class="line">export PATH CLASSPATH JAVA_HOME</span><br><span class="line"><span class="meta">#</span><span class="bash">记得刷新配置文件</span></span><br><span class="line">source /etc/profile</span><br><span class="line"><span class="meta">#</span><span class="bash">退出编辑模式 左手按住esc 右手<span class="built_in">shift</span>+:   :q!不保存退出 :wq保存退出</span></span><br><span class="line"><span class="meta">#</span><span class="bash">文本编辑器  *****</span></span><br><span class="line">vi a.txt</span><br><span class="line"><span class="meta">#</span><span class="bash">进入编辑模式 按i</span></span><br></pre></td></tr></table></figure>

<h2 id="Xshell连接Linux"><a href="#Xshell连接Linux" class="headerlink" title="Xshell连接Linux"></a>Xshell连接Linux</h2><h3 id="Linux中的配置"><a href="#Linux中的配置" class="headerlink" title="Linux中的配置"></a>Linux中的配置</h3><p><img src="https://pic.baixiongz.com/2020/07/15/25ffdc8e4ba82.png" alt="image.png"></p>
<p>Xshell中的配置（服务器地址不知道在Linux中使用ip addr命令查看）</p>
<p><img src="https://pic.baixiongz.com/2020/07/15/f2e48d58bd171.png" alt="image.png"></p>
<p>出现了如下所示表示连接成功</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Last login: Wed Jul <span class="number">15</span> <span class="number">03</span>:<span class="number">38</span>:<span class="number">54</span> <span class="number">2020</span> from <span class="number">192.168</span>.xx.x</span><br><span class="line">[root@localhost ~]#</span><br></pre></td></tr></table></figure>

<p>在官网中下载Redis，下载地址为：<a href="http://www.redis.cn/" target="_blank" rel="noopener">http://www.redis.cn/</a></p>
<p>也可使用<code>wget</code>命令进行下载(版本问题去官网查询)：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget http:<span class="comment">//download.redis.io/releases/redis-4.0.8.tar.gz</span></span><br></pre></td></tr></table></figure>

<p>解压</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zxvf redis-<span class="number">4.0</span><span class="number">.8</span>.tar.gz</span><br></pre></td></tr></table></figure>

<p>就可以获取到解压之后的源码包<code>redis-4.0.8</code>，之后进入到该目录中。</p>
<p>在进入到该目录下输入命令：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make</span><br></pre></td></tr></table></figure>

<p>就开启了<code>Redis</code>的编译状态，在编译完成之后可以看到类似如下的信息提示：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make[<span class="number">1</span>]: Leaving directory `/mnt/vdb/software/redis-<span class="number">4.0</span><span class="number">.8</span>/src<span class="string">'</span></span><br></pre></td></tr></table></figure>

<p>应当运行<code>make test</code>命令</p>
<p>源码文件被移动到当前目录的<code>src</code>文件夹下面。</p>
<p>进入到源码目录<code>src</code>下，输入对应的安装命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd src</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

<p>安装完成之后的提示结果为：</p>
<p>Hint: It’s a good idea to run ‘make test’ ;</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">INSTALL install</span><br><span class="line">INSTALL install</span><br><span class="line">INSTALL install</span><br><span class="line">INSTALL install</span><br><span class="line">INSTALL install</span><br></pre></td></tr></table></figure>
<p>进入到<code>bin</code>目录下面，进行Redis服务的启动：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./redis-server</span><br></pre></td></tr></table></figure>

<p><img src="https://pic.baixiongz.com/2020/07/15/5f7bb74466cb9.png" alt="image.png"></p>
<p>可以设置后台运行:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">进入到redis文件夹下下面运行</span></span><br><span class="line">vim redis.conf</span><br><span class="line"><span class="meta">#</span><span class="bash">修改</span></span><br><span class="line"><span class="meta">#</span><span class="bash">按i键编辑</span></span><br><span class="line">daemonize yes</span><br><span class="line"><span class="meta">#</span><span class="bash">Esc后:wq保存 :q!不保存</span></span><br><span class="line"><span class="meta">#</span><span class="bash">再运行</span></span><br><span class="line">redis-server redis.conf</span><br><span class="line"><span class="meta">#</span><span class="bash">通过redis.conf运行</span></span><br><span class="line">redis-cli</span><br><span class="line"><span class="meta">#</span><span class="bash">后台运行执行成功</span></span><br></pre></td></tr></table></figure>

<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost redis-6.0.5]# redis-cli</span><br><span class="line"><span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">6379</span>&gt; </span><br><span class="line">#后台运行结果</span><br></pre></td></tr></table></figure>


        </div>
      </div>
    </div>
  </div>
</article>



    <!-- Footer -->
<footer>
  <div class="container">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <p class="copyright text-muted">
          Theme By <a target="_blank" href="https://github.com/levblanc">Levblanc.</a>
          Inspired By <a target="_blank" href="https://github.com/klugjo/hexo-theme-clean-blog">Clean Blog.</a>
        <p class="copyright text-muted">
          Powered By <a target="_blank" href="https://hexo.io/">Hexo.</a>
        </p>
      </div>
    </div>
  </div>
</footer>


    <!-- After Footer Scripts -->

<script src="/myblog/js/highlight.pack.js"></script>

<script>
  document.addEventListener("DOMContentLoaded", function(event) {
    var codeBlocks = Array.prototype.slice.call(document.getElementsByTagName('pre'))
    codeBlocks.forEach(function(block, index) {
      hljs.highlightBlock(block);
    });
  });
</script>

  </body>
</html>

